From 51044ea80b6623f513fb3772ffdb4fed44f76636 Mon Sep 17 00:00:00 2001 From: justbur Date: Thu, 12 Nov 2015 13:23:59 -0500 Subject: [PATCH] Add option to pad key columns on the left Allows you to make more space between the columns if you think the layout is too tight. --- README.org | 6 +++++- which-key.el | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 8e56c9dbcf6..4a7a4e3daac 100644 --- a/README.org +++ b/README.org @@ -411,9 +411,13 @@ shown. (setq which-key-idle-delay 1.0) ;; Set the maximum length (in characters) for key descriptions (commands or - ;; prefixes). Descriptions that are longer are truncated and have ".." added + ;; prefixes). Descriptions that are longer are truncated and have ".." added. (setq which-key-max-description-length 27) + ;; Use additonal padding between columns of keys. This variable specifies the + ;; number of spaces to add to the left of each column. + (setq which-key-add-column-padding 0) + ;; Set the separator used between keys and descriptions. Change this setting to ;; an ASCII character if your font does not show the default arrow. The second ;; setting here allows for extra padding for Unicode characters. which-key uses diff --git a/which-key.el b/which-key.el index f24f0d156dc..d875ffff2ea 100644 --- a/which-key.el +++ b/which-key.el @@ -68,6 +68,12 @@ Also adds \"..\". If nil, disable any truncation." :group 'which-key :type 'integer) +(defcustom which-key-add-column-padding 0 + "Additional padding (number of spaces) to add to the left of +each key column." + :group 'which-key + :type 'integer) + (defcustom which-key-separator " → " "Separator to use between key and description." :group 'which-key @@ -1258,7 +1264,8 @@ element in each list element of KEYS." "Take a column of (key separator description) COL-KEYS, calculate the max width in the column and pad all cells out to that width." - (let* ((col-key-width (which-key--max-len col-keys 0)) + (let* ((col-key-width (+ which-key-add-column-padding + (which-key--max-len col-keys 0))) (col-sep-width (which-key--max-len col-keys 1)) (col-desc-width (which-key--max-len col-keys 2)) (col-width (+ 1 col-key-width col-sep-width col-desc-width))) -- 2.30.2